#include<iostream>
using namespace std;

class Solution
{
public:
    void printTable() {
        int n = 0;
        //一个袋子装6个 或者 8个
        for(int appleNum = 1; appleNum <= 100; appleNum++) {
            int ret = f(appleNum);
            int ret2 = g(appleNum);
            if(ret != ret2) {
                cout << "oppos" << endl;
                cout << appleNum << endl;
            }
            // if(appleNum % 2 == 0) {
            //     cout << "apple num:" << appleNum
            //         << "\treturn:" << ret << endl;
            // }
        }
    }
    //贪心
    int f(int n) {
        int num = n;
        while(num >= 0) {
            if(num % 8 == 0) {
                return num / 8 + (n - num) / 6;
            }
            num -= 6;
        }
        return -1;
    }
    //根据贪心获取的打表
    int g(int n) {
        if(n % 2 == 1 || n < 6 || n == 10) {
            return -1;
        }
        return (n - 1) / 8 + 1;
    }
};


int main() {
    // Solution().printTable();
    int n;
    cin >> n;
    cout << Solution().g(n) << endl;
    return 0;
}